<template>
  <div style="width: 100vw; height: 85vh;">
    <div class="line" >
        <LineChart :title="title1" :myChart="myChart1" :datalist="datalist1" @getinvent="getInventory1"></LineChart>
    </div>
    <div class="line" >
        <LineChart :title="title2" :myChart="myChart2" :datalist="datalist2" @getinvent="getInventory2"></LineChart>
    </div>
  </div>
</template>

<script>
import request from '@/utils/request'
import LineChart from './components/LineChart'
export default {
    name:'jstGoodsqueryInventory',
    components:{LineChart},
    data() {
        return {
            myChart1:'chart1',
            myChart2:'chart2',
            title1:'在库库存',
            title2:'采购在途',
            datalist1: [],
            datalist2: [],
        }
    },
    created() {
    },
    methods: {
        getInventory1(data){
        if (!data) {
          data={}
        }
        const config={
          url: 'api/jstGoods/queryInventory',
          methods: 'get',
          params: data
        }
        request(config).then(res=>{
            if (res.data.content.length===0) {
                this.datalist1=[]
            }else{
                this.datalist1=[]
                for (const key in res.data.content[0]) {
                let u=/^usableQty.*/
                if(u.test(key)){
                this.datalist1.push(res.data.content[0][key])
                }
            }
            }
        //   
        })
      },
        getInventory2(data){
        if (!data) {
          data={}
        }
        const config={
          url: 'api/jstGoods/queryInventory',
          methods: 'get',
          params: data
        }
        request(config).then(res=>{
            if (res.data.content.length===0) {
                this.datalist2=[]
            }else{
                this.datalist2=[]
                for (const key in res.data.content[0]) {
                let u=/^purchaseQty.*/
                if(u.test(key)){
                this.datalist2.push(res.data.content[0][key])
                }
            }
            }
        //   
        })
      },
    },
}
</script>

<style lang="scss" scoped>
    .line{
        max-width: 90%;
        height: 50%;
    }
</style>